package com.example.statistics.ui.customer

import android.os.Bundle
import com.example.statistics.R
import com.example.statistics.common.BaseActivity
import com.example.statistics.ex.bottomSingleDialog
import com.example.statistics.ex.post
import com.example.statistics.net.UrlConfig
import com.example.statistics.utils.activityFinish
import com.jhj.httplibrary.model.HttpParams
import kotlinx.android.synthetic.main.activity_customer_add.*

class CustomerAddActivity : BaseActivity() {

    override val title: String
        get() = "联系人"

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_customer_add)

        topBarRightText("保存") {
            val params = HttpParams()
            params.put(
                    "name" to il_name.contentText,
                    "nameSpelling" to il_name.contentText,
                    "phone" to il_phone.contentText,
                    "avatar" to il_phone.contentText,
                    "type" to il_type.contentText,
                    "attribute" to il_attribute.contentText,
                    "company" to il_company.contentText,
                    "product" to il_product.contentText,
                    "city" to il_city.contentText,
                    "address" to il_address.contentText,
                    "remark" to il_remark.contentText
                    )
            post<String>(UrlConfig.CUSTOMER_ADD, true, params) {
                activityFinish()
            }
        }

        il_type.onSelector {
            bottomSingleDialog(list = listOf("牛", "猪", "虾尾", "龙虾", "串", "巴沙鱼")) { alertFragment, s ->
                il_type.contentText = s
            }
        }
        il_attribute.contentText = "猪"
        il_attribute.onSelector {
            bottomSingleDialog(list = listOf("冻品批发", "加工厂", "冷鲜肉", "熟食", "干调", "港口")) { alertFragment, s ->
                il_attribute.contentText = s
            }
        }

    }

}